package com.bw;

import cn.hutool.core.util.RandomUtil;
import com.bw.entity.OrderInfo;
import com.bw.service.OrderService;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.UUID;

public class TestAdd {

    public static void main(String[] args) {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-ioc.xml");

        OrderService orderService = applicationContext.getBean(OrderService.class);



        for (int i = 0; i < 2001; i++) {
            OrderInfo info = new OrderInfo();
            //订单编号生成，保证唯一性
            String orderNum = UUID.randomUUID().toString();
            info.setOrderNum(orderNum);
            //币种随机生成
            // 随机一个 1-7位数
            int currencyId = RandomUtil.randomInt(1, 8);
            info.setCurrencyId(currencyId);
            //持仓金额随机生成
            String banlance = RandomUtil.randomInt(1, 9999) + "";
            info.setBalance(banlance);
            if (i<500){
                info.setProductNum("p123");
            }
            if (i>= 500 && i<1000){
                info.setProductNum("p456");
            }
            if (i>= 1000){
                info.setProductNum("p789");
            }
            info.setPhone("17611221735");
            info.setUserNum("u001");
            orderService.add(info);
        }



    }


}
